import type { CalendarEvent, EventParam } from "@/types/calendar"
import { http } from "@/utils/http"

//创建新日程
export const creatEventAPI = (data: EventParam) => {
    return http({
        method: 'POST',
        url: '/api/events',
        data
      })
}

//更新日程
export const updateEventAPI = (id: string ,data: EventParam) => {
  return http({
      method: 'PUT',
      url: `/api/events/${id}`,
      data
    })
}

//根据获取某日期范围内的所有日程
export const getEventInfoAPI = (data: CalendarEvent) => {
    return http<CalendarEvent[]>({
      method: 'POST',
      url: '/api/events/getEventsByMonth',
      data
    })
}

//删除
export const deleteEventInfoAPI = (id: string) => {
  return http<CalendarEvent[]>({
    method: 'DELETE',
    url: `/api/events/${id}`,
  })
}

//获取某一日期的日程
export const getDaliyEventInfoAPI = (date: string) => {
  return http<CalendarEvent[]>({
    method: 'GET',
    url: `/api/events/getByDate/${date}`,
  })
}